/*
 * File:   ucgrid1d.h
 * Author: oddi
 *
 * Created on October 3, 2010, 1:17 PM
 */

#ifndef _UCGRID1D_H
#define	_UCGRID1D_H

#ifndef _GLOBAL_DEFINITIONS_H
#include "global_definitions.h"
#endif
#include "particles.h"


//Uniform carthesian grid 1d
//stores density of charge particles,
//values of electric and magnetic fields

#ifdef	__cplusplus
extern "C" {
#endif

#define CELLTYPE_ERROR     -1
#define CELLTYPE_REGULAR    1
#define CELLTYPE_LEFTBOUND  2
#define CELLTYPE_RIGHTBOUND 3

    typedef struct struct_init_grid
    {
        floatdig min_z;
        floatdig max_z;
        floatdig numofcells;
    } init_ucgrid1d;

    typedef struct struct_ucgrid1d {
        int cellsize;
        init_ucgrid1d parameters;
    } ucgrid1d;

    typedef ucgrid1d* pucgrid1d;

    void ucgrid1d_init_grid(init_ucgrid1d*, ucgrid1d*);
    void ucgrid1d_clear_grid(ucgrid1d*);
    void ucgrid1d_get_cell_center_pos(ucgrid1d*, int cellnum, floatdig* pos);
    __forceinline__ __device__ int ucgrid1d_get_nearest_cell_cuda(floatdig cellsize, floatdig pos, int *cell)
    {
        return (int)(pos/cellsize);
    }

#ifdef DEBUG
    int ucgrid1d_distribute_particles_debug(particles_set* set, ucgrid1d* grid);
#endif

#ifdef	__cplusplus
}
#endif

#endif	/* _UCGRID1D_H */

